package com.ssy.lingxi.common.constant.marketing;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 平台优惠券类型枚举
 * @author yzc
 * @version 2.0.0
 * @date 2021/6/28
 */
public enum PlatformCouponTypeEnum {

    /**
     * 0元购买抵扣券 - 1
     */
    ZERO_DISCOUNT(1, "0元购买抵扣券"),

    /**
     * 平台通用优惠券 - 2
     */
    COMMON(2, "平台通用优惠券");

    private final Integer code;
    private final String message;

    PlatformCouponTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getCodeMessage(Integer code) {
        PlatformCouponTypeEnum status = Arrays.stream(PlatformCouponTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return status == null ? "未知" : status.getMessage();
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

    public static PlatformCouponTypeEnum parse(Integer code) {
        return Arrays.stream(PlatformCouponTypeEnum.values()).filter(v -> v.getCode().equals(code)).findFirst().orElse(null);
    }

}